package top.jasonlam.car.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.swing.text.StyledEditorKit;
import java.util.Set;


/**
 * 级联关系  user 级联 car  carSet  ===》 汽车发布单
 * username 用户名
 * password 密码
 * realName 用户真实姓名
 * phone 用户手机号
 * vip 用户身份
 * pushable ？？？
 *
 * @author jasonlam
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "user")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class User {
    @Id
    @Column(name = "username", nullable = false, unique = true, length = 20)
    private String username;

    @Column(name = "password", nullable = false, length = 20)
    private String password;

    @Column(name = "realName", nullable = false, length = 20)
    private String realName;

    @Column(name = "phone", nullable = false, length = 13)
    private String phone;

    @Column(name = "vip", nullable = false)
    private Boolean vip;

    @Column(name = "pushable", nullable = false)
    private Boolean pushable;

    @OneToMany(targetEntity = Car.class, cascade = {CascadeType.ALL}, mappedBy = "username")
    Set<Car> carSet;
}
